import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class SelectItemView extends StatefulWidget {
  bool isSelected;
  bool isSingleSelect;
  String? text;
  VoidCallback? onTap;
  SelectItemView({
    this.isSelected = false,
    this.isSingleSelect = true,
    this.text,
    this.onTap,
  });

  @override
  State<StatefulWidget> createState() => _SelectItemViewState();
}

class _SelectItemViewState extends State<SelectItemView> {
  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () {
        if (widget.onTap != null) widget.onTap!();
      },
      child: Container(
        padding: EdgeInsets.all(10.w),
        decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(5.w),
            color: widget.isSelected ? Color(0x44009669) : Colors.white,
            border: Border.all(
                width: 1.w,
                color:
                    widget.isSelected ? Color(0xFF009669) : Color(0xFFD8D8D8))),
        child: Row(
          children: [
            Image.asset(
              widget.isSelected
                  ? (widget.isSingleSelect
                      ? 'assets/images/ic_single_checked.png'
                      : 'assets/images/ic_multi_checked.png')
                  : (widget.isSingleSelect
                      ? 'assets/images/ic_single_check_no.png'
                      : 'assets/images/ic_multi_check_no.png'),
              width: 16.w,
              height: 16.w,
            ),
            SizedBox(
              width: 10.w,
            ),
            Expanded(
                child: Text(
              widget.text ?? '',
              style: TextStyle(color: Color(0xFF646464), fontSize: 14.sp),
            ))
          ],
        ),
      ),
    );
  }
}
